﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <Style x:Key="MetroTabControl"  TargetType="TabControl" >
        <Setter Property="Background" Value="{x:Null}" />
        <Setter Property="Margin" Value="5 5 5 5" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TabControl}">
                    <Grid KeyboardNavigation.TabNavigation="Local">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <TabPanel  Name="HeaderPanel" Grid.Row="0" Panel.ZIndex="1"  IsItemsHost="True" KeyboardNavigation.TabIndex="1" Background="Transparent" />
                        <Border Name="Border" Grid.Row="1" Background="{x:Null}"
                                BorderBrush="{DynamicResource TextBoxBorderBrush}" BorderThickness="1 1 1 1" 
                                CornerRadius="0"  KeyboardNavigation.TabNavigation="Local" KeyboardNavigation.DirectionalNavigation="Contained" KeyboardNavigation.TabIndex="2" >
                            <ContentPresenter  Name="PART_SelectedContentHost" Margin="4" ContentSource="SelectedContent" />
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Foreground" Value="{StaticResource DisabledForegroundBrush}" />
                            <Setter TargetName="Border" Property="BorderBrush" Value="{StaticResource DisabledBorderBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


    <Style TargetType="TabItem" x:Key="MetroTabItem">
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="Padding" Value="6,2,6,2" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="VerticalContentAlignment" Value="Stretch" />
        <Setter Property="MinWidth" Value="5" />
        <Setter Property="MinHeight" Value="5" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="TabItem">
                    <Border x:Name="border" Background="{DynamicResource ControlBackgroundBrush}" BorderBrush="{DynamicResource TextBoxBorderBrush}" BorderThickness="0" Margin="0 0 1 0">
                        <Label x:Name="root" FontSize="{DynamicResource ContentFontSize}">
                            <ContentPresenter ContentSource="Header"  RecognizesAccessKey="True" />
                        </Label>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsSelected" Value="true">
                            <Setter TargetName="root" Property="Foreground">
                                <Setter.Value>
                                    <SolidColorBrush Color="{DynamicResource AccentColor}" />
                                </Setter.Value>
                            </Setter>
                            <Setter TargetName="border" Property="BorderBrush" Value="{DynamicResource TextBoxBorderBrush}" />
                            <Setter TargetName="border" Property="BorderThickness" Value="1 1 1 0" />                            
                            <Setter TargetName="root" Property="BorderBrush" Value="{DynamicResource ControlBackgroundBrush}" />
                            <Setter TargetName="root" Property="BorderThickness" Value="0 0 0 3" />
                            <Setter TargetName="root" Property="Margin" Value="0 0 0 -2" />
                        </Trigger>
                        <Trigger Property="IsSelected" Value="false">
                            <Setter  TargetName="root" Property="Foreground">
                                <Setter.Value>
                                    <SolidColorBrush Color="{DynamicResource GrayNormal}" />
                                </Setter.Value>
                            </Setter>
                            <Setter TargetName="border" Property="Margin" Value="1 -1 1 1" />
                        </Trigger>
                        <Trigger SourceName="root" Property="IsMouseOver" Value="True">
                            <Setter  TargetName="root" Property="Foreground">
                                <Setter.Value>
                                    <SolidColorBrush Color="{DynamicResource GrayHover}" />
                                </Setter.Value>
                            </Setter>                            
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>